prepare("SELECT * FROM questions WHERE exam_id = ? ORDER BY id"); $stmt->execute([$exam_id]); $questions = $stmt->fetchAll(PDO::FETCH_ASSOC); // Handle question deletion if (isset($_GET['delete_question'])) { $question_id = sanitize_input($_GET['delete_question']); try { $stmt = $pdo->prepare("DELETE FROM questions WHERE id = ?"); $stmt->execute([$question_id]); // Update exam question count $stmt = $pdo->prepare("UPDATE exams SET total_questions = (SELECT COUNT(*) FROM questions WHERE exam_id = ?) WHERE id = ?"); $stmt->execute([$exam_id, $exam_id]); $success = "Question deleted successfully!"; redirect("view_questions.php?exam_id=$exam_id"); } catch (PDOException $e) { $error = "Error deleting question: " . $e->getMessage(); } } ?>
Subject: | Total Questions:
Upload questions using the Excel upload feature or add them manually.
📤 Upload Questions